package io.github.kouleen.manager.listener.server;

import io.github.kouleen.minecraft.core.lang.annotation.MinecraftPluginListener;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.server.ServiceUnregisterEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.RegisteredServiceProvider;

/**
 * 当一个服务从服务器的服务管理器中注销时，会触发该事件。
 * @author zhangqing
 * @since 2025/2/26 11:13
 */
@MinecraftPluginListener
public class ServiceUnregisterListener implements Listener {

    @EventHandler
    public void onServiceUnregisterListener(ServiceUnregisterEvent serviceUnregisterEvent){
        RegisteredServiceProvider<?> unregisterEventProvider = serviceUnregisterEvent.getProvider();
        Plugin plugin = unregisterEventProvider.getPlugin();
        PluginDescriptionFile pluginDescriptionFile = plugin.getDescription();
        System.out.println(plugin.getName() + pluginDescriptionFile.getVersion() + "被注销了");
    }
}
